

import java.util.ArrayList;

import logic.MySQLconnection;
import Entities.InspectionEntity;
import Entities.RequestEntity;
import fit.ActionFixture;
import gui.AcademicFrame;
import gui.ServerGui;

public class Inspect extends ActionFixture
{
	ServerGui server;
	AcademicFrame client;
	String insID;
	String code;
	public void setupfixture()
	{
		server = new ServerGui();
		server.fakeServer(5555, "mysql://localhost/test", "root", "Braude");
		server.myLog.setVisible(false);
		client = new AcademicFrame("Localhost",5555);
		
	}
	public void setInsID (String ID)
	{
		insID = ID;
	}
	
	public void setCode (String code1)
	{
		code=code1;
	}
	  
	public boolean inspection()
	{
		ArrayList<Object> answer = new ArrayList<Object>();
		ArrayList<Object> question = new ArrayList<Object>();
		InspectionEntity en = new InspectionEntity();
		en.setRequestID(insID);
		en.setFaults("test");
		question.add("setInspectionData");
		question.add(en);
		if(code.equals("approve"))
			question.add("approve");
			else question.add("deny");
		client.myclient.sendMessageToServer(question);
		while (client.answer==null);
		answer = client.answer;
		client.answer=null;
	
		if(answer.get(2).equals("statusSet") || answer.get(2).equals("Valid"))
			return true;
		else
			return false;
	}
}
